Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@ledgerhq/logs
Advanced tools
@ledgerhq/logs is an npm package designed to facilitate logging within applications that interact with Ledger hardware wallets. It provides a simple and consistent way to log messages, which can be useful for debugging and monitoring the behavior of applications.
Basic Logging
This feature allows you to log messages with a specific type and level. In this example, 'apdu' is the type, 'message' is the content, and 'debug' is the level of the log.
const { log } = require('@ledgerhq/logs');
log('apdu', 'message', 'debug');
Custom Log Listener
You can set up a custom listener to handle log messages. This example demonstrates how to listen for log events and print them to the console.
const { listen } = require('@ledgerhq/logs');
listen(log => {
console.log(log.type, log.message, log.level);
});
Winston is a versatile logging library for Node.js that supports multiple transports (e.g., console, file, HTTP). It is more feature-rich compared to @ledgerhq/logs, offering advanced features like log levels, custom formats, and more.
Bunyan is another logging library for Node.js that focuses on JSON output for structured logging. It provides features like log levels, serializers, and streams. Bunyan is more suitable for applications that require structured logs and advanced logging capabilities.
Pino is a fast and low-overhead logging library for Node.js. It is designed for high-performance logging and provides features like log levels, serializers, and transports. Pino is ideal for applications that need efficient and performant logging.
Utility library that is used by all Ledger libraries to dispatch logs so we can deal with them in a unified way.
A Log object
log something
type
string a namespaced identifier of the log (it is not a level like "debug", "error" but more like "apdu-in", "apdu-out", etc...)message
string? a clear message of the log associated to the typedata
any?listen to logs.
cb
function (Log): void that is called for each future log() with the Log objectReturns Unsubscribe a function that can be called to unsubscribe the listener
FAQs
Ledger logs central point
We found that @ledgerhq/logs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 21 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.